function updateBITS_pscd(i, j)
% PCparams structure is implicit parameter
%
% Non-Recursive implementation of the SCD update BITS routine
%

global PCparams;
N = PCparams.N;
n = PCparams.n;
PI = PCparams.PI;
if(i>=N || j>=n)
    %fprintf('into %d,%d\n',i,j);
    return 
end
s = 2^(PI(n-j)+1);
l = mod(i,s);
s_2 = fix(s/2);
if(l < s_2)
    return 
else
    %fprintf('BITSa=%d,BITSb=%d\n',i+1,i-s_2+1);
    PCparams.BITSpscd(i-s_2+1,j+2)=mod(PCparams.BITSpscd(i+1,j+1)+PCparams.BITSpscd(i-s_2+1,j+1),2);
    PCparams.BITSpscd(i+1,j+2) = PCparams.BITSpscd(i+1,j+1);
    updateBITS_pscd(i,j+1);
    updateBITS_pscd(i-s_2,j+1);
end
end